﻿using System;
using System.Collections;
using System.Collections.Generic;

#if UNITY_EDITOR
using UnityEditor;
#endif

namespace UnityEngine
{
	[Serializable]
	public class PrefabStartupTile : BaseTile
	{
		public Sprite m_Sprite;
		public GameObject m_Prefab;

		public override bool GetTileData(Vector3Int location, ITileMap tileMap, ref TileData tileData)
		{
			tileData.sprite = m_Sprite;
			tileData.transform = Matrix4x4.identity;
			tileData.color = Color.white;
			tileData.gameobject = m_Prefab;
			return true;
		}

		public override bool StartUp(Vector3Int location, ITileMap tileMap, GameObject go)
		{
			Debug.Log(String.Format("StartUp was called for PrefabStartupTile"));
			return true;
		}

		public override Sprite GetPreview()
		{
			return m_Sprite;
		}

#if UNITY_EDITOR
		[MenuItem("Assets/Create/Prefab Startup Tile")]
		public static void CreatePrefabStartupTile()
		{
			string path = EditorUtility.SaveFilePanelInProject("Save Prefab Startup Tile", "New Tile", "asset", "Save Tile", "Assets");

			if (path == "")
				return;

			AssetDatabase.CreateAsset(ScriptableObject.CreateInstance<PrefabStartupTile>(), path);
		}
#endif
	}
}
